home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / amixpr / intxpr.asm < prev    next >
Encoding:
Assembly Source File  |  1996-02-18  |  23.5 KB  |  994 lines

  1.  
  2.  
  3.         SECTION  AMIXPR,CODE    ;(c)1992 Gellermann +49/621/715101-0
  4.  
  5.         incdir   "include/"
  6.         include  "exec/exec_lib.i"
  7.         include  "intuition/intuition.i"
  8.         include  "intuition/intuition_lib.i"
  9.         include  "libraries/dos_lib.i"
  10.         include  "libraries/dosextens.i"
  11.         include  "devices/serial.i"
  12.         include  "devices/timer.i"
  13.         include  "graphics/graphics_lib.i"
  14.         include  "graphics/text.i"
  15.     xdef _xprsequence
  16.      xref _CallersLog
  17.      xref _UDLog
  18.      xref _MYScreen
  19.      xref _ReceivePath
  20.      xref _xprinit
  21.      xref _protocol
  22.      xref _SendPath
  23.      xref _sendopt
  24.      xref _DOSBase
  25.      xref _IntuitionBase
  26.      xref _myxprunit
  27.      xref _myxprdevice
  28.      xref _GfxBase
  29.      xref _DTBT
  30.      xref _TBT
  31.      xref _TTTM
  32.      xref _TTEFF
  33.      xref _TTCPS
  34.      xref _Online_NFiles
  35.      xref _BatchXfer
  36. _xprsequence:
  37. ;located here bcuz the doslib must be open for printHELP but
  38. ;the xprlib must not be open since we have yet to determine
  39. ;the xpr_protocolname
  40.                 ;decode the switches
  41. main_loop
  42.      moveq    #0,d0
  43.      move.l   _protocol,a1
  44.      CALLEXEC OpenLibrary
  45.      tst.l    d0
  46.      bne      XPRok
  47.      rts
  48. XPRok
  49.         move.l   d0,_XPRBase
  50.  
  51.         lea      SerIO,a1        ;IOExtSer Struktur
  52.         clr.l    d0         
  53.         clr.l    d1
  54.        move.b      _myxprunit,d0
  55.         move.b   #$B4,IO_SERFLAGS(a1)    ;set radboogie,7wire,(shared=b4)
  56.         move.l   _myxprdevice,a0        ;exclusive = $94
  57.         CALLEXEC OpenDevice
  58.         tst.l    d0
  59.         bne      ClSer
  60.  
  61.         sub.l    a1,a1            ;Replyport einrichten
  62.         CALLEXEC FindTask        ;eigenen Task eintragen
  63.         lea      SerReply,a1
  64.         move.l   d0,MP_SIGTASK(a1) 
  65.         CALLEXEC AddPort        ;reply (message-)port einrichten
  66.         lea      SerIO,a1        ;replyport eintragen
  67.         move.l   #SerReply,MN_REPLYPORT(a1)
  68.  
  69. ;---------------------------------------;OPEN DEVICES
  70.  
  71.         lea      TimeIO,a1        ;timer.device
  72.         move.l   #UNIT_MICROHZ,d0
  73.         clr.l    d1
  74.         lea      timer_name,a0
  75.         CALLEXEC OpenDevice
  76.         sub.l    a1,a1
  77.         CALLEXEC FindTask
  78.         lea      TimeReply,a1
  79.         move.l   d0,MP_SIGTASK(a1)
  80.         CALLEXEC AddPort
  81.         lea      TimeIO,a1        ;replyport eintragen
  82.         move.l   #TimeReply,MN_REPLYPORT(a1)
  83.  
  84.  
  85. ;---------------------------------------;ALLOC RAM
  86.     move.l    #10000,d0        ;Logbuffer
  87.     move.l    #$30001,d1
  88.     CALLEXEC    AllocMem
  89.     tst.l    d0
  90.     beq    noRAM
  91.     move.l    d0,LBMin
  92.         bsr      MAINEVENT
  93.      move.l    LBMin,a1
  94.      move.l    #10000,d0
  95.      CALLEXEC    FreeMem
  96. noRAM
  97.         lea      TimeIO,a1
  98.         CALLEXEC CloseDevice
  99.         lea      TimeReply,a1
  100.         CALLEXEC RemPort
  101. ClTimer
  102.         lea      SerIO,a1
  103.         CALLEXEC CloseDevice
  104.         lea      SerReply,a1
  105.         CALLEXEC RemPort
  106. ClSer
  107. ClFont
  108.         move.l   _XPRBase,a1
  109.         CALLEXEC CloseLibrary
  110.         move.l  #0,d0            ;Return Code 0 = OK
  111.         rts
  112.  
  113. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  114. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  115. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  116. MAINEVENT
  117.      move.l #0,_DTBT     ;clear xfer stats
  118.      move.l #0,_TBT
  119.      move.l #0,_TTTM
  120.      move.l #0,_TTEFF
  121.      move.l #0,_TTCPS
  122.      move.l #0,_Online_NFiles
  123.      bsr ResetTmps
  124.      move.l #msg,tex        ;write-pointer
  125.      move.l #20,yps          ;y-Startposition
  126.      move.l #0,d0
  127.      move.b _sendopt,d0
  128.      tst.b d0
  129.      bne noRECEIVE
  130.      bsr    Receive
  131.     rts
  132. noRECEIVE
  133.      bsr Send
  134.      rts
  135. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  136. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  137. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  138. Receive    ;"amixpr r path"
  139.     ;        ^Pointer
  140.  
  141.         lea      XPR_IO,a0
  142.         move.l   _xprinit,(a0)
  143.         move.l   _XPRBase,a6
  144.         jsr      -36(a6)        ;Setup general params
  145.  
  146.        move.l      _ReceivePath,a2
  147.         move.b   #"P",(a2)
  148.         lea      XPR_IO,a0
  149.         move.l   a2,(a0)
  150.         move.l   _XPRBase,a6
  151.         jsr      -36(a6)        ;Setup receive path
  152.  
  153.     bsr     openWINDOW
  154.  
  155.         lea      XPR_IO,a0
  156.         move.l   _XPRBase,a6
  157.         jsr      -48(a6)        ;Receive
  158.  
  159.     bsr     closeWINDOW
  160.  
  161.         lea      XPR_IO,a0
  162.         move.l   _XPRBase,a6
  163.         jsr      -30(a6)        ;Cleanup
  164.  
  165.         rts
  166.  
  167. Send    ;amixpr s path/name1 path/name2 ... 256bytes max (use -b !!!)
  168.     ;       ^Pointer
  169.  
  170.        bsr     openWINDOW
  171.         lea      XPR_IO,a0
  172.         move.l   _xprinit,(a0)
  173.         move.l   _XPRBase,a6
  174.         jsr      -36(a6)        ;Setup general params
  175.  
  176.         move.l   _SendPath,a1            
  177.         lea      XPR_IO,a0
  178.        move.l   a1,(a0)        ;give pointer to ffirst/fnext
  179.        move.l   _XPRBase,a6
  180.        jsr      -42(a6)        ;Send
  181.  
  182.        bsr     closeWINDOW
  183.  
  184.        lea      XPR_IO,a0
  185.        move.l   _XPRBase,a6
  186.        jsr      -30(a6)        ;Cleanup
  187.     rts
  188.  
  189. ResetTmps  ;clear the cps, eff, & time temp variables
  190.      move.l #0,TmpCps
  191.      move.l #0,TmpEff
  192.      move.l #0,TmpTim
  193.      move.l #0,TmpSiz
  194.      rts
  195.  
  196. AddTmps    ;add the temp variables to the main ones.
  197.      move.l d0,-(SP)
  198.      move.l TmpCps,d0
  199.      add.l d0,_TTCPS
  200.      move.l TmpEff,d0
  201.      add.l d0,_TTEFF
  202.      move.l TmpTim,d0
  203.      add.l d0,_TTTM
  204.      
  205.      move.b _sendopt,d0
  206.      tst.b d0
  207.      beq noRecSize
  208.      move.l TmpSiz,d0
  209.      add.l d0,_TBT
  210.      move.l #1,d0
  211.      add.l d0,_Online_NFiles
  212. noRecSize
  213.      move.l (SP)+,d0
  214.      bsr ResetTmps
  215.      rts
  216.  
  217. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
  218. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
  219. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
  220. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  221. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  222. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  223. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  224. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  225. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  226. ;--------------------------------------XPR CALLBACK ROUTINEN--------------
  227. ;
  228. ;----------------------------------xpr_fopen
  229. xpr_fopen    ;a0^FileName a1^Axxsmode return:d0=handle or 0
  230.  
  231.     move.l  a0,d1
  232.     move.b    (a1),d0
  233.     bclr.l    #5,d0        ;cap. letters
  234.     cmpi.b    #"R",d0
  235.         bne    noMODE_READ
  236.         move.l    #MODE_OLDFILE,d2
  237.         CALLDOS    Open        ;d1^name d2=modus
  238.     rts
  239.  
  240. noMODE_READ
  241.         cmpi.b    #"W",d0
  242.         bne    noMODE_WRITE
  243.         move.l    #MODE_NEWFILE,d2
  244.         CALLDOS    Open
  245.     rts
  246.  
  247. noMODE_WRITE
  248.         cmpi.b    #"A",d0
  249.         bne    noMODE_APPEND
  250.     move.l    d1,d5           ;save ^name
  251.         move.l    #MODE_OLDFILE,d2
  252.         CALLDOS    Open
  253.         tst.l    d0
  254.         bne    OPENok
  255.     move.l    d5,d1
  256.         move.l    #MODE_NEWFILE,d2
  257.         CALLDOS    Open
  258.     rts
  259. OPENok
  260.     move.l     d0,d5        ;save handle
  261.         move.l   d0,d1        ;goto end of file (append)
  262.         move.l   #0,d2
  263.         move.l   #OFFSET_END,d3
  264.         CALLDOS  Seek
  265.     move.l     d5,d0        ;handle in d0 must be returned
  266.     rts
  267.  
  268. noMODE_APPEND
  269.     clr.l    d0
  270.     rts            ;do nothing
  271.  
  272. ;----------------------------------xpr_fclose
  273. xpr_fclose
  274.     move.l    a0,d1
  275.     CALLDOS    Close
  276.      bsr AddTmps
  277.     rts
  278.  
  279. ;the fclose is the only callback-routine that gets
  280. ;called after every filexfer in a batch
  281. ;so we build a string of log entries
  282. ;here and save it after the xprlib returns.
  283. ;----------------------------------xpr_fread
  284. xpr_fread
  285.              move.l  d1,d3  ;Laenge
  286.              move.l  a0,d2  ;Buffer
  287.              move.l  a1,d1  ;Handle
  288.              CALLDOS Read
  289.              rts
  290. ;----------------------------------xpr_fwrite
  291. xpr_fwrite
  292.              move.l  d1,d3  ;Laenge
  293.              move.l  a0,d2  ;Buffer
  294.              move.l  a1,d1  ;Handle
  295.              CALLDOS Write
  296.              rts
  297. ;----------------------------------xpr_fseek
  298. xpr_fseek
  299.              move.l  d1,d3  ;Modus offset_beginning/current/end
  300.              move.l  d0,d2  ;Abstand
  301.              move.l  a0,d1  ;Handle
  302.              subq.l  #1,d3
  303.              CALLDOS Seek
  304.              tst.l   d0
  305.              bmi.s   fseek1
  306.              clr.l   d0 ;0=success
  307. fseek1
  308.              rts
  309. ;----------------------------------xpr_finfo
  310. xpr_finfo
  311.  
  312.         MOVE.L  D0,-(SP)
  313.         MOVE.L  A0,D1
  314.         MOVE.L  #-2,D2
  315.         CALLDOS Lock
  316.         MOVE.L  D0,D1
  317.         BEQ     finfo2
  318.         MOVE.L  D0,-(SP)
  319.         MOVE.L  D0,D1
  320.         MOVE.L  #FIB,D2
  321.         CALLDOS Examine
  322.         MOVE.L  (SP)+,D1
  323.         CALLDOS UnLock
  324.         MOVE.L  (SP),D0
  325.         CMP.L   #2,D0
  326.         BEQ     finfo1
  327.         CMP.L   #1,D0
  328.         BNE     finfo2
  329.         lea     FIB,a0
  330.         move.l  124(a0),d0 ;anzahl bytes
  331.         BRA     finfo3
  332. finfo1  CLR.L   D0
  333.         BRA     finfo3
  334. finfo2  CLR.L   D0
  335. finfo3  CLR.L   (SP)+
  336.         RTS
  337. ;----------------------------------xpr_update
  338. xpr_update
  339. ;the most important routine for isdn: gets called between
  340. ;every 1k block transfered.. keep it very simple and fast ore it
  341. ;will take away 2000cps.. no `%complete` calculation and stuff..
  342.  
  343.         move.l  a0,Asave        ;save ptr to xpr_update (build_log)
  344.        move.l    (a0),d5        ;update mask (what fields have changed)
  345.  
  346. ;-------
  347.     btst.l    #1,d5    
  348.     beq    noFileName
  349.  
  350.         move.l  #11*8,d0    
  351.         move.l  #20,d1        ;filename
  352.         bsr     updatemove
  353.     move.l    #Fill,a0
  354.     move.l    #40,d0
  355.     bsr    updatetext
  356.         move.l  #11*8,d0    
  357.         move.l  #20,d1
  358.         bsr     updatemove
  359.         move.l  Asave,a0
  360.         move.l  8(a0),a0    ;^Fname
  361.         clr.l   d0
  362.         move.l  a0,a1
  363. update0
  364.     cmpi.b  #15,(a1)+
  365.         bcs     update4
  366.         addq.b  #1,d0
  367.     cmpi.b    #40,d0        ;print max 40 chars
  368.     bne    update0
  369. update4
  370.     bsr     updatetext
  371.  
  372. noFileName
  373. ;-------
  374.     btst.l    #2,d5    
  375.     beq    noFileSize
  376.  
  377.         move.l  Asave,a0
  378.         move.l  12(a0),d0    ;filesize
  379.         move.l  12(a0),TmpSiz
  380.         lea     Ruelps,a0
  381.         bsr     ULONGtoASCII
  382.         move.l  #11*8,d0
  383.         move.l  #30,d1
  384.         bsr     updatemove
  385.         lea     Ruelps,a0
  386.         move.l  #8,d0
  387.         bsr     updatetext
  388. noFileSize
  389. ;-------
  390.     btst.l    #3,d5    
  391.     beq    noMSG
  392.  
  393.         move.l  #1*8,d0    
  394.         move.l  #90,d1
  395.         bsr     updatemove
  396.     move.l    #Fill,a0
  397.     move.l    #50,d0
  398.     bsr    updatetext
  399.         move.l  #1*8,d0    
  400.         move.l  #90,d1
  401.         bsr     updatemove
  402.         move.l  Asave,a0
  403.         move.l  16(a0),a0
  404.         clr.l   d0
  405.         move.l  a0,a1
  406. update00
  407.     cmpi.b  #15,(a1)+
  408.         bcs     update44
  409.         addq.b  #1,d0
  410.     cmpi.b    #50,d0        ;print max 50 chars
  411.     bne    update00
  412. update44
  413.     bsr     updatetext
  414. noMSG
  415. ;-------
  416.     btst.l    #4,d5
  417.     beq    noERROR
  418.  
  419.         move.l  #1*8,d0    
  420.         move.l  #100,d1    
  421.         bsr     updatemove
  422.     move.l    #Fill,a0
  423.     move.l    #50,d0
  424.     bsr    updatetext
  425.         move.l  #1*8,d0    
  426.         move.l  #100,d1    
  427.         bsr     updatemove
  428.         move.l  Asave,a0
  429.         move.l  20(a0),a0
  430.         clr.l   d0
  431.         move.l  a0,a1
  432. update000
  433.     cmpi.b  #15,(a1)+
  434.         bcs     update444
  435.         addq.b  #1,d0
  436.     cmpi.b    #50,d0        ;print max 50 chars
  437.     bne    update000
  438. update444
  439.     bsr     updatetext
  440. noERROR
  441. ;-------
  442.     btst.l    #16,d5
  443.     beq    noCPS
  444.  
  445.         move.l  Asave,a0
  446.         move.l  68(a0),d0    ;cps
  447.         move.l  d0,TmpCps
  448.         lea     Ruelps,a0
  449.         bsr     ULONGtoASCII
  450.         move.l  #11*8,d0
  451.         move.l  #70,d1
  452.         bsr     updatemove
  453.         lea     Ruelps,a0
  454.         move.l  #8,d0
  455.         bsr     updatetext
  456. noCPS
  457. ;-------
  458.     btst.l    #7,d5
  459.     beq    noBYTES
  460.  
  461.         move.l  Asave,a0    
  462.         move.l  32(a0),d0    ;position
  463.         lea     Ruelps,a0
  464.         bsr     ULONGtoASCII
  465.         move.l  #11*8,d0
  466.         move.l  #40,d1
  467.         bsr     updatemove
  468.         lea     Ruelps,a0
  469.         move.l  #8,d0
  470.         bsr     updatetext
  471. noBYTES
  472. ;-------
  473.     btst.l    #15,d5
  474.     beq    noELAPSED
  475.  
  476.         move.l  #11*8,d0
  477.         move.l  #60,d1
  478.         bsr     updatemove
  479.         move.l  Asave,a0
  480.         move.l  64(a0),a0    ;^elapsed time
  481.         move.l  #8,d0        ;maxlen
  482.         bsr     updatetext
  483. noELAPSED
  484. ;-------
  485.     btst.l    #14,d5
  486.     beq    noEXPECT
  487.  
  488.         move.l  #11*8,d0
  489.         move.l  #50,d1
  490.         bsr     updatemove
  491.         move.l  Asave,a0
  492.         move.l  60(a0),a0    ;^expect time
  493.         move.l  #8,d0        ;maxlen
  494.         bsr     updatetext
  495. noEXPECT
  496. ;-------
  497. update_end
  498.         rts
  499.  
  500. ;----------------------------------xpr_chkabort
  501. xpr_chkabort    ;abort if ESCAPE or CLOSEWINDOW or CARRIER LOST
  502.         ;also called between every 1k block
  503.  
  504.         move.l   UDwindowptr,a0    ;IDCMP-Windowport holen
  505.         move.l   wd_UserPort(a0),a0
  506.         CALLEXEC GetMsg
  507.         tst.l    d0
  508.         beq      noMESSAGE
  509.  
  510.         move.l   d0,a1
  511.         move.l   im_Class(a1),d4
  512.         move.w   im_Code(a1),d5 ;.Word!
  513.     CALLEXEC ReplyMsg
  514.  
  515.         cmpi.l   #CLOSEWINDOW,d4
  516.         beq      yoABORT
  517.     cmpi.l     #RAWKEY,d4
  518.     bne     xpr_chkabort
  519.     cmpi.b     #$45,d5
  520.     beq     yoABORT    ;escape key pressed (only when win active)
  521.         bra     xpr_chkabort     ;another msg?
  522.  
  523. noMESSAGE
  524.         bsr     xpr_squery     ;vielleicht zu lang fuer isdn?
  525.     move.w     IO_STATUS(a1),d0
  526.         btst     #5,d0        ;CARRIER LOST?
  527.     bne     yoABORT
  528. noABORT
  529.         clr.l   d0 
  530.         rts
  531. yoABORT
  532.         move.l   #-1,d0        ;d0 nonzero = abort
  533.         rts
  534.  
  535.  
  536. ;----------------------------------xpr_chkmisc
  537. xpr_chkmisc 
  538.     rts
  539. ;----------------------------------xpr_sread
  540. xpr_sread
  541.  
  542.         move.l   a0,Anull    ;IO_DATA
  543.         move.l   d0,Dnull       ;IO_LENGTH
  544.         move.l   d1,Deins    ;timeout or 0
  545.  
  546.         tst.l    d1        ;timeout gefordert ?
  547.         bne      wantsTIMEOUT    ;wenn ja
  548.  
  549.         bsr      xpr_squery     ;read all bytes available
  550.         tst.l    d0        ;IO_ACTUAL
  551.         bne      sumTHERE
  552.         rts                     ;return with count=0
  553.  
  554. sumTHERE
  555.         cmp.l    Dnull,d0
  556.         bcc      readOK        ;more than asked for?
  557.         move.l   d0,Dnull    ;read only as much as requested
  558. readOK
  559.         lea      SerIO,a1
  560.         move.w   #CMD_READ,IO_COMMAND(a1)
  561.         move.l   Dnull,IO_LENGTH(a1)
  562.         move.l   Anull,IO_DATA(a1)
  563.         CALLEXEC DoIO
  564.         move.l   IO_ACTUAL(a1),d0
  565.         rts
  566.  
  567.  
  568. wantsTIMEOUT
  569.         lea      SerIO,a1
  570.         move.w   #CMD_READ,IO_COMMAND(a1)
  571.         move.l   Dnull,IO_LENGTH(a1)
  572.         move.l   Anull,IO_DATA(a1)
  573.         CALLEXEC SendIO        ;DoIO would not return
  574.  
  575.         lea      TimeIO,a1
  576.         move.w   #TR_ADDREQUEST,IO_COMMAND(a1)
  577.         move.l   Deins,$24(a1)    ;timeout in microsecs
  578.         move.l   #0,$20(a1)    ;0 secs
  579.         CALLEXEC SendIO
  580.  
  581. ;--------
  582. waitEVENT
  583.         clr.l    d0        ;wait: either asked # of bytes arrive or
  584.         clr.l    d1        ;timerequest returns (timeout)
  585.  
  586.         lea      SerReply,a1    ;generate waitmaske
  587.         move.b   MP_SIGBIT(a1),d1
  588.         bset.l   d1,d0
  589.  
  590.         lea      TimeReply,a1
  591.         move.b   MP_SIGBIT(a1),d1
  592.         bset.l   d1,d0
  593.  
  594.         CALLEXEC Wait        ;timeout!enough_bytes
  595.  
  596. ;--------
  597.         lea      SerIO,a1    ;ok, iam back who signaled me?
  598.         CALLEXEC CheckIO    ;was it the SerReqptr?
  599.         beq      noSERIAL
  600.         CALLEXEC WaitIO        ;SERIAL did it: cleanup serial
  601.  
  602.         lea      TimeIO,a1    ;abort timer
  603.         CALLEXEC AbortIO
  604.         lea      TimeIO,a1
  605.         CALLEXEC WaitIO        ;cleanup timer
  606.  
  607.         lea      SerIO,a1
  608.         move.l   IO_ACTUAL(a1),d0 ;probably the IO_ACTUAL = # of asked bytes
  609.         rts
  610.  
  611. ;-------
  612. noSERIAL
  613.         lea      TimeIO,a1    ;timeout?
  614.         CALLEXEC CheckIO
  615.         beq      noTIMER    ;something else did it...return to sleep
  616.         CALLEXEC WaitIO        ;TIMER did it: cleanup timer
  617.  
  618.         lea       SerIO,a1    ;abort serial
  619.         CALLEXEC AbortIO
  620.         lea       SerIO,a1
  621.         CALLEXEC WaitIO        ;cleanup serial
  622.  
  623.         lea      SerIO,a1
  624.         move.l   IO_ACTUAL(a1),d0 ;probably IO_ACTUAL=0
  625.         rts
  626. ;-------
  627. noTIMER
  628.     bra     waitEVENT
  629.  
  630. ;----------------------------------xpr_swrite
  631. xpr_swrite
  632.  
  633.         lea      SerIO,a1
  634.         move.w   #CMD_WRITE,IO_COMMAND(a1)
  635.         move.l   d0,IO_LENGTH(a1)
  636.         move.l   a0,IO_DATA(a1)
  637.         CALLEXEC DoIO
  638.         rts
  639. ;----------------------------------xpr_sflush
  640. xpr_sflush
  641.  
  642.         lea      SerIO,a1
  643.         move.w   #CMD_FLUSH,IO_COMMAND(a1)
  644.         CALLEXEC DoIO
  645.         rts
  646. ;----------------------------------xpr_squery
  647. xpr_squery
  648.  
  649.         lea       SerIO,a1
  650.         move.w   #SDCMD_QUERY,IO_COMMAND(a1)
  651.         CALLEXEC DoIO
  652.         move.l   IO_ACTUAL(a1),d0
  653.         rts
  654. ;----------------------------------xpr_unlink
  655. xpr_unlink
  656.  
  657.         MOVE.L  A0,D1
  658.         CALLDOS DeleteFile
  659.         TST.L   D0
  660.         BEQ     unlink1
  661.         MOVEQ   #-$1,D0
  662.         BRA     unlink2
  663. unlink1 CLR.L   D0
  664. unlink2 RTS
  665. ;---------------------------------xpr_getptr
  666. xpr_getptr
  667.         CLR.L        D0
  668.         RTS
  669. ;---------------------------------xpr_options
  670. xpr_options
  671.         RTS
  672. ;---------------------------------xpr_ffirst
  673. xpr_ffirst    ;a0^buffer in which we must copy the first filename,0
  674.         ;a1^xpr_filename (from lib-call)
  675.  
  676.     tst.b    (a1)        ;"amixpr s ",0
  677.     beq    ffirst_null
  678.     cmpi.b    #" ",(a1)    ;"amixpr s  ",0
  679.     beq    ffirst_null
  680.  
  681. ffirst_loop
  682.     move.b    (a1)+,(a0)+
  683.  
  684.     tst.b    (a1)
  685.     beq    ffirst_end    
  686.  
  687.     cmpi.b    #" ",(a1)
  688.     beq    ffirst_end
  689.     bra    ffirst_loop
  690.  
  691. ffirst_end
  692.     move.b    #0,(a0) ;terminate name with zero
  693.     move.l    a1,d0    ;wird fnext uebergeben in d0!
  694.         rts
  695.  
  696. ffirst_null
  697.     clr.l    d0    ;no file found
  698.         rts
  699. ;---------------------------------xpr_fnext
  700. xpr_fnext    ;a0^buffer for the next filename
  701.  
  702.     move.l    d0,a1        ;erwarte in d0 ^ auf ende vom letzten namen
  703.                                 ;                   oldname oldname
  704.     tst.b    (a1)+           ;                                  ^
  705.     beq    fnext_null    ;"oldname",0
  706.     tst.b    (a1)
  707.     beq    fnext_null    ;"oldname ",0
  708.     cmpi.b    #" ",(a1)
  709.     beq    fnext_null      ;"oldname  "
  710.  
  711. fnext_loop
  712.     move.b    (a1)+,(a0)+
  713.  
  714.     tst.b    (a1)
  715.     beq    fnext_end    
  716.  
  717.     cmpi.b    #" ",(a1)    ;liest solange bis er ein space findet    
  718.     beq    fnext_end
  719.     bra    fnext_loop
  720.  
  721. fnext_end
  722.     move.b    #0,(a0)
  723.     move.l    a1,d0
  724.     rts
  725.  
  726. fnext_null
  727.     clr.l    d0    ;no file found
  728.         rts
  729.  
  730.  
  731. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  732. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  733. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  734. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  735. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  736. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  737. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  738. ;-=-=-=-= PROCEDURES -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  739.  
  740.  
  741. ;----------------------------------
  742. updatemove                         ;d0=x;d1=y
  743.         move.l   UDwindowptr,a1
  744.         move.l   wd_RPort(a1),a1
  745.         CALLGRAF Move                
  746.         rts
  747. updatetext                         ;a0=^buffer;d0=anzahl
  748.         move.l   UDwindowptr,a1
  749.         move.l   wd_RPort(a1),a1
  750.         CALLGRAF Text
  751.         rts
  752.  
  753. ;----------------------------------
  754. openWINDOW
  755.      move.l _MYScreen,d0
  756.      lea    SPTR,a0
  757.      move.l d0,(a0)
  758.     lea    UDwindowdef(pc),a0    ;infowindow auf.
  759.     CALLINT    OpenWindow
  760.     move.l    d0,UDwindowptr
  761.  
  762.     move.l    UDwindowptr,a1
  763.     move.l    wd_RPort(a1),a1
  764.     move.l    #1,d0
  765.     CALLGRAF    SetAPen        ;colour of text in window
  766.  
  767.     move.l    UDwindowptr,a1
  768.     move.l    wd_RPort(a1),a1
  769.  
  770.     move.l    #1*8,d0    
  771.     move.l    #76,d1            ;ypos stripe
  772.     bsr    updatemove
  773.  
  774.     move    #51*8,d0    
  775.     move    #76,d1    
  776.     move.l  UDwindowptr,a1
  777.     move.l    wd_RPort(a1),a1
  778.     CALLGRAF    Draw
  779.  
  780.     moveq    #5,d5            ;Anzahl Zeilen -1
  781. text    moveq    #1*8,d0            ;Text ausgeben
  782.     move.l    yps,d1
  783.     move.l    UDwindowptr,a1
  784.     move.l    wd_RPort(a1),a1
  785.     CALLGRAF    Move        ;Cursor setzen
  786.     move.l    UDwindowptr,a1
  787.     move.l    wd_RPort(a1),a1
  788.     move.l    tex,a0
  789.     moveq    #50,d0
  790.     CALLGRAF    Text
  791.     add.l    #10,yps            ;1 Zeile =10 Pixel hoch
  792.     add.l    #50,tex            ;1 Zeile =20 Zeichen
  793.     dbra    d5,text
  794.  
  795. noopenWINDOW
  796.     rts
  797. ;---------------------------------------;
  798. closeWINDOW
  799.         move.l   UDwindowptr,a0
  800.         CALLINT  CloseWindow        
  801. nocloseWINDOW
  802.     rts
  803. ;---------------------------------------;
  804.  
  805.  
  806.  
  807. ;--------------------------------------------
  808. ULONGtoASCII    ;a0->8byte Buffer for the String; d0=ULONG to work on
  809.                 ;this is ULONGtoDecimalstring not ULONGtoHEX$
  810.  
  811.         movem.l    d1/d2/a1,-(a7)
  812.  
  813.         moveq    #7,d2    ;8 digits...
  814.         lea.l    Potenzen,a1
  815. next
  816.         move    #"0",d1
  817. make1
  818.         addq    #1,d1
  819.         sub.l    (a1),d0
  820.         bcc    make1
  821.         subq    #1,d1
  822.         add.l    (a1),d0
  823.         move.b    d1,(a0)+
  824.         tst.l    (a1)+
  825.         dbra    d2,next
  826.  
  827.         movem.l    (a7)+,d1/d2/a1
  828.         rts
  829.  
  830. Potenzen    dc.l    10000000
  831.         dc.l    1000000
  832.         dc.l    100000
  833.         dc.l    10000
  834.         dc.l    1000
  835.         dc.l    100
  836.         dc.l    10
  837.         dc.l    1
  838.         dc.l    0
  839.         cnop    0,4
  840.  
  841.  
  842. ;---------------------------------------;
  843. HEXStringULONG    ;a0^HEX$(8byte) a1^ULONG(4byte)
  844.  
  845.     movem.l    d0/d1/d2/a2,-(a7)    ;save the registers we use
  846.     move.l    #3,d1            ;not a0! (must count on)
  847. HEX00
  848.     move.b    (a0)+,d0    ;get first asciibyte
  849.     bset.l    #5,d0        ;only small chars. digits unchanged
  850.     move.l    #15,d2          ;0123456789abcde or f
  851.     lea    HEXTAB(pc),a2
  852. HEX02
  853.     cmp.b    (a2,d2),d0
  854.     beq    HEX01
  855.     dbra    d2,HEX02
  856. HEX01
  857.     mulu    #16,d2        ;d2=position in hextab (0-15)
  858.     move.b    d2,(a1)        ;high nibble (*16)
  859.     move.b    (a0)+,d0    ;same with the low nibble
  860.     bset.l    #5,d0        ;change to small char
  861.     move.l    #15,d2
  862. HEX03
  863.     cmp.b    (a2,d2),d0
  864.     beq    HEX04
  865.     dbra    d2,HEX03
  866. HEX04
  867.         add.b    d2,(a1)+    ;add to highnib
  868.     dbra    d1,HEX00    ;4 times (e.g.: 00 c0 12 34)
  869.     movem.l    (a7)+,d0/d1/d2/a2
  870.     rts
  871.  
  872. HEXTAB    dc.b    "0123456789abcdef"
  873.     cnop    0,4
  874.  
  875. ;---------------------------------------;
  876.  
  877. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  878. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  879. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  880. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  881. ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  882. ;-=-=-=-= DATA -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  883.  
  884. XPR_IO
  885.     dc.l    0
  886.     dc.l    xpr_fopen    ;a pointer to this struct must be given
  887.     dc.l    xpr_fclose    ;whenever calling a xprlib function
  888.     dc.l    xpr_fread
  889.     dc.l    xpr_fwrite
  890.     dc.l    xpr_sread
  891.     dc.l    xpr_swrite
  892.     dc.l    xpr_sflush
  893.     dc.l    xpr_update
  894.     dc.l    xpr_chkabort
  895.     dc.l    xpr_chkmisc
  896.     dc.l    0        ;xpr_gets    ;not implemented
  897.     dc.l    0        ;xpr_setserial    ;not implemented
  898.     dc.l    xpr_ffirst
  899.     dc.l    xpr_fnext
  900.     dc.l    xpr_finfo
  901.     dc.l    xpr_fseek
  902.     dc.l    4        ;alle 4 EXT fields programmiert
  903.     dc.l    0
  904.     dc.l    xpr_options    ;EXT1
  905.     dc.l    xpr_unlink    ;EXT2
  906.     dc.l    xpr_squery    ;EXT3
  907.     dc.l    xpr_getptr    ;EXT4
  908.     dc.l    0,0,0,0
  909.     cnop    0,4
  910.  
  911. ;----------------------------------------------
  912. SerIO        ds.b    96    ;IOExtSer  Alloc for Message and Replyports
  913. SerReply    ds.b    48
  914.  
  915. ;----------------------------------------------
  916. TimeIO        ds.b    48
  917. TimeReply    ds.b    48
  918. ;----------------------------------------------
  919.         cnop    0,4
  920.  
  921. UDwindowdef
  922.         dc.w    14*8,5*8    ;coordinates of left-top edge
  923.         dc.w    52*8,14*8       ;x/y size
  924.         dc.b    -1,-1
  925.         dc.l    CLOSEWINDOW!RAWKEY
  926.         dc.l    UDW_Gadgets!UDW_Extras
  927.         dc.l    0
  928.         dc.l    0
  929.         dc.l    UDW_Title
  930. SPTR        dc.l    _MYScreen        ;SCREENPOINTER
  931.         dc.l    0
  932.         dc.w    0,0
  933.         dc.w    0,0
  934. STYPE        dc.w    CUSTOMSCREEN    ;SCREENTYPE
  935.         cnop    0,4
  936.  
  937. UDW_Gadgets    equ    WINDOWDRAG!WINDOWCLOSE
  938. UDW_Extras    equ    SMART_REFRESH!ACTIVATE
  939.         cnop    0,4
  940.  
  941. _XPRBase        dc.l    0
  942. UDwindowptr    dc.l    0
  943. Asave        dc.l    0
  944. Anull        dc.l    0
  945. Aeins        dc.l    0
  946. Dnull        dc.l    0
  947. Deins        dc.l    0
  948. LBMin    dc.l    0    ;^start of allocated logbuffer
  949.         cnop    0,4
  950.  
  951. ;-------
  952.  
  953.  
  954. Ruelps    dc.b    "........",0
  955.     cnop    0,4
  956. Fill    dc.b    "                                                  " ;LEN=50
  957.     cnop    0,4
  958. ;-------
  959. msg    dc.b    "FileName:                                         " ;20
  960.     dc.b    "FileSize:          :                              " ;30
  961.     dc.b    "Position:          :                              " ;40
  962.     dc.b    "APX Time:          :                              " ;50
  963.     dc.b    " Elapsed:          :                              " ;60
  964.     dc.b    "     CPS:          :                              " ;70
  965.     cnop    0,4
  966. tex    dc.l    msg        ;write-pointer
  967. yps    dc.l    20        ;y-Startposition
  968. ;-------
  969.  
  970. TmpCps dc.l 0
  971. TmpEff dc.l 0
  972. TmpTim dc.l 0
  973. TmpSiz dc.l 0
  974.  
  975. UDW_Title    dc.b    "         AmiXpress Transfer Window               ",0
  976.         cnop    0,4
  977. int_name    INTNAME
  978.         cnop    0,4
  979. timer_name    TIMERNAME
  980.         cnop    0,4
  981. dos_name    DOSNAME
  982.         cnop    0,4
  983. graf_name    GRAFNAME
  984.         cnop    0,4
  985.  
  986. FIB        ds.b    260        ;file-info-block alloc
  987.         cnop    0,4
  988.  
  989. ;---------------------------------------------------------------------
  990.              END
  991. ;---------------------------------------------------------------------
  992.  
  993.  
  994.